package threadLock.threadBasics;

import java.util.concurrent.Callable;

public class CreateThread {

    /**
     * 使用继承Thread类 重写run方法来获取一个线程
     */
    public static class ThreadExtend extends Thread {
        @Override
        public void run() {
            System.out.println("this is extend Thread class create Thread");
        }
    }

    /**
     * 实现了runnable接口 必须实现run()方法 来获取一个线程
     */
    public static class ThreadRunnable implements Runnable {
        @Override
        public void run() {
            System.out.println("this is implement Runnable interface create Thread,Manual running can be achieve");
        }
    }

    /**
     * 实现了callable接口 必须实现call方法 获取线程
     * 当前线程的好处是 可以携带线程处理之后的返回值
     */
    public static class CallerTask implements Callable<String>{

        @Override
        public String call() throws Exception {
            return "this is implement Callable interface create Thread,Manual running can be achieve and carry return value and it is an asynchronous task";
        }
    }
}
